package com.tensquare.qa.dao;

import com.tensquare.qa.pojo.Problem;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author: Feng.Wang
 * @Company: Zelin.ShenZhen
 * @Description:
 * @Date: Create in 2019/3/23 16:32
 */
@Repository
public interface ProblemDao  extends JpaRepository<Problem,String>,JpaSpecificationExecutor<Problem>{
    /**
     * 根据标签id查询其下的最新问题列表
     * @param labelid
     * @param pageable
     * @return
     */
    @Query(nativeQuery=true,
            value = "SELECT id,title,content,createtime,updatetime,userid,nickname,reply,visits,thumbup,solve,replyname,replytime FROM tb_problem,tb_pl WHERE problemid=id AND labelid=?1 " +
            "ORDER BY createtime DESC")
    public Page<Problem> findNewlistByLabelId(String labelid, Pageable pageable);
}
